package mdocejb.servlet;

import java.io.IOException;

import javax.ejb.EJB;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import entityBeans.ContactGroup;

import sessionBeans.Interfaces.IGestContactGroupRemote;

/**
 * Servlet implementation class DeleteContactGroup
 */
public class DeleteContactGroup extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@EJB(name = "GestContactGroupEntity")
	private IGestContactGroupRemote GCGR;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public DeleteContactGroup() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		Long id = Long.valueOf(request.getParameter("grid")).longValue();

		if (id != null) {
			ContactGroup cgToDelete = GCGR.find(id);
			GCGR.delete(cgToDelete);
		}
		response.sendRedirect("LoadGroups");
	}

}
